  <?php
/**
 * @package JoiCaddy
 * @copyright Авторские права (C) 2008-2010 Joostina team. Все права защищены.
 * @license Лицензия http://www.gnu.org/licenses/gpl-2.0.htm GNU/GPL, или help/license.php
 * JoiCaddy - свободное программное обеспечение распространяемое по условиям лицензии GNU/GPL
 * JoiCaddy основан на разработках SimpleCaddy от Henk von Pickartz
 */


// запрет прямого доступа
defined('_VALID_MOS') or die();

class display {
    private function option( $value, $text='', $value_name='value', $text_name='text', $disable=false )
	{
		$obj = new stdClass;
		$obj->$value_name	= $value;
		$obj->$text_name	= trim( $text ) ? $text : $value;
		$obj->disable		= $disable;
		return $obj;
	}
    private function published( &$row, $i, $imgY = 'tick.png', $imgX = 'publish_x.png', $prefix='' )
	{
		$img 	= $row->published ? $imgY : $imgX;
		$task 	= $row->published ? 'unpublish' : 'publish';
		$alt 	= $row->published ? 'Published' : 'Unpublished';
		$action = $row->published ? 'Unpublish Item' : 'Publish item';

		$href = '
		<a href="javascript:void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $prefix.$task .'\')" title="'. $action .'">
		<img src="images/'. $img .'" border="0" alt="'. $alt .'" /></a>'
		;

		return $href;
	}

	function showExport() {
		display::header(EXPORT);
		?>
		<form method="post" name="adminForm" action="index2.php">
			<input type="hidden" name="option" value="com_caddy" />
			<input type="hidden" name="action" value="orders" />
			<input type="hidden" name="task" value="show" />
			<input type="hidden" name="boxchecked" value="0" />
			<input type="hidden" name="hidemainmenu" value="0" />
		</form>
		<?php
		echo "Your export can be downloaded : <a href='components/com_caddy/exports/export.txt'>here</a>";
	}

	function MainMenu($message="") {
		display::header(MAIN);
	?>
		<table border="1" class="adminform">
		<tr>
		<td width="55%" valign="top">

		<div id="cpanel">

			<div style="float:left;">
				<div class="icon">
				<a title="<?php echo SC_PRODUCTS; ?>" href="index2.php?option=com_caddy&amp;action=products&amp;task=show">
				<img src="components/com_caddy/images/products.png" alt="<?php echo SC_MANAGE_PRODUCTS;?>" align="middle" name="image" border="0" /><br />
				<?php echo SC_PRODUCTS; ?></a>
				</div>
			</div>

			<div style="float:left;">
				<div class="icon">
				<a title="<?php echo SC_ORDERS; ?>" href="index2.php?option=com_caddy&amp;action=orders&amp;task=show">
				<img src="components/com_caddy/images/orders.png" alt="<?php echo SC_MANAGE_ORDERS;?>" align="middle" name="image" border="0" /><br />
				<?php echo SC_ORDERS; ?></a>
				</div>
			</div>

			<div style="float:left;">
				<div class="icon">
				<a title="<?php echo SC_VOUCHERS; ?>" href="index2.php?option=com_caddy&amp;action=vouchers&amp;task=show">
				<img src="components/com_caddy/images/vouchers.png" alt="<?php echo SC_MANAGE_VOUCHERS;?>" align="middle" name="image" border="0" /><br />
				<?php echo SC_VOUCHERS; ?></a>
				</div>
			</div>

			<div style="float:left;">
				<div class="icon">
				<a title="<?php echo SC_OPTION_FIELDS; ?>" href="index2.php?option=com_caddy&amp;action=fields&amp;task=show">
				<img src="components/com_caddy/images/fields.png" alt="<?php echo SC_MANAGE_FIELDS;?>" align="middle" name="image" border="0" /><br />
				<?php echo SC_OPTION_FIELDS; ?></a>
				</div>
			</div>

			<div style="float:left;">
				<div class="icon">
				<a title="<?php echo SC_CONFIGURATION; ?>" href="index2.php?option=com_caddy&amp;action=configuration&amp;task=show">
				<img src="components/com_caddy/images/config.png" alt="<?php echo SC_CONFIGURATION;?>" align="middle" name="image" border="0" /><br />
				<?php echo SC_CONFIGURATION; ?></a>
				</div>
			</div>

			<div style="float:left;">
				<div class="icon">
				<a title="<?php echo SC_SHIPPING; ?>" href="index2.php?option=com_caddy&amp;action=shipping&amp;task=show">
				<img src="components/com_caddy/images/shipping.png" alt="<?php echo SC_SHIPPING;?>" align="middle" name="image" border="0" /><br />
				<?php echo SC_SHIPPING; ?></a>
				</div>
			</div>

			<div style="float:left;">
				<div class="icon">
				<a title="About" href="index2.php?option=com_caddy&amp;action=about&amp;task=show">
				<img src="components/com_caddy/images/about.png" alt="About" align="middle" name="image" border="0" /><br />
				<?php echo SC_ABOUT; ?></a>
				</div>
			</div>
		</div>

		</td>
		<td valign="top">
		<?php
			echo "$message";
		?>
		</td>
		</tr>
		</table>
	<?php
	}

	function AFFooter() {
		?>
		<div><div align="center">
<!--		--><?php //echo 'SimpleCaddy v1.72, for more information click here';?>
<!--		<a href="http://atlanticintelligence.net" target="_blank">Information</a>-->
<!--		<br /><a href="http://demo15.atlanticintelligence.net" target="_blank">--><?php //echo 'Click here for demo';?><!--</a>-->
		</div></div>
		<?php
	}

	function showAbout() {
		global $mainframe;
		//jimport('joomla.filesystem.path');
		display::header(SC_ABOUT);
	?>
		<form name="adminForm">
		<input type="hidden" name="task" />
		<input type="hidden" name="option" value="com_caddy" />
		</form>
		<div align="left">
		<h2><img src="components/com_caddy/images/sc_logo15.png"  />JoiCaddy для Joostina 1.3.0</h2>
		Добавляет базовую функциональность корзины на любую страницу содержания Joostina.
		<br/>Возможности
		  <ul>
			  <li>Добавление в корзину</li>
			  <li>Простой механизм покупки</li>
			  <li>Простое управление заказами</li>
			  <li>Простое управление магазином</li>
			  <li>Заказ на е-майл</li>
			  <li>Оплата на PayPal</li>
			  <li>Индивидуальные варианты товара</li>
			  <li>Формулы для определения цены отдельных вариантов</li>
			  <li>Купоны</li>
		  </ul>
		  </div>
		  <p>JoiCaddy основан на  SimpleCaddy (c)Henk von Pickartz, 2006-2010</p>
		  <p>Shipping module (c)Cole Diffin, 2010</p>
	<?php
	}
	
	function showSortArrows($fieldname) {
		echo "<a href=\"javascript:submitme('$fieldname,ASC')\"><img src=\"images/uparrow.png\" border=\"0\" /></a>";
		echo "<a href=\"javascript:submitme('$fieldname,DESC')\"><img src=\"images/downarrow.png\" border=\"0\" /></a>";
	}

	function showProducts(&$arows, $field=null, $order=null) {
	global $mainframe, $mosConfig_list_limit, $mosConfig_absolute_path;
		display::header(SIMPLECADDY_PRODUCTS);
		$cfg=new sc_configuration();
		$currency=$cfg->get("currency");
		$tsep=$cfg->get("thousand_sep");
		$decsep=$cfg->get("decimal_sep");
		$decs=$cfg->get("decimals");
		$pageNav=$arows['nav'];
		$rows=$arows['lst'];
		$lists=$arows['lists'];
		$search=mosGetParam($_REQUEST, "search");
		?>
		<script language="javascript">
			function submitme(option) {
			a=option.split(",");
			document.adminForm.field.value=a[0];
			document.adminForm.order.value=a[1];
			document.adminForm.submit();
			}
		</script>
		<form method="post" name="adminForm" action="index2.php">

			<table>
				<tr>
					<td width="100%">
						<?php echo 'Filter'; ?>:
						<?php echo $lists['category'];?>
					</td>
				</tr>
			</table>


				<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
					<tr>
						<th width="20">
							<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" />
						</th>

						<th class="title" nowrap="nowrap"><?php echo SC_CODE ?>&nbsp;<?php echo display::showSortArrows("prodcode");?></th>
						<th class="title" nowrap="nowrap"><?php echo SC_DESCRIPTION ?>&nbsp;<?php echo display::showSortArrows("shorttext");?></th>
						<th class="title" nowrap="nowrap"><?php echo SC_PRODUCT_CATEGORY ?>&nbsp;<?php echo display::showSortArrows("category");?></th>
						<th class="title tdright" nowrap="nowrap"><?php echo SC_PRICE_PER_UNIT ?>&nbsp;<?php echo display::showSortArrows("unitprice");?></th>
						<th class="title tdright" nowrap="nowrap"><?php echo SC_NUM_IN_STORE ?>&nbsp;<?php echo display::showSortArrows("av_qty");?></th>
						<th class="title tdcenter" nowrap="nowrap"><?php echo SC_PUBLISHED ?>&nbsp;<?php echo display::showSortArrows("published");?></th>
						<th class="title" nowrap="nowrap">&nbsp;</th>

					</tr>
				<?php
				$k = 0;
				for ($i=0, $n=count( $rows ); $i < $n; $i++) {
				$row = &$rows[$i];
				?>
					<tr class="<?php echo "row$k"; ?>">
						<td width="20">
							<input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" />
						</td>
						<td width="10%">
							<a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')">
							<?php
							echo $row->prodcode; ?>
							</a>
						</td>
						<td width="40%">
							<?php echo $row->shorttext; ?>
						</td>
						<td width="40%">
							<?php echo $row->category; ?>
						</td>
						<td width="10%" class="tdright">
							<?php
							echo number_format($row->unitprice, $decs, $decsep, $tsep);
							?>
						</td>
						<td width="10%" class="tdright">
							<?php echo $row->av_qty; ?>
						</td>
						<td align="left" width="10%" class="tdcenter">
							<?php
								$published 	= self::published($row, $i );
								echo $published;
							?>
						</td>
						<td>
							&nbsp;
						</td>
			<?php
				$k = 1 - $k; }

			?>
				</tr>
				<tr><td colspan="7">
					<?php
						echo $pageNav->getListFooter();
					?>
				</td></tr>
			</table>
			<input type="hidden" name="option" value="com_caddy" />
			<input type="hidden" name="action" value="products" />
			<input type="hidden" name="task" value="" />
			<input type="hidden" name="field" value="<?php echo $field;?>" />
			<input type="hidden" name="order" value="<?php echo $order;?>" />
			<input type="hidden" name="boxchecked" value="0" />
			<input type="hidden" name="hidemainmenu" value="0" />
		</form>
		<?php
	}

	function showFields(& $arows ) {
	global $mainframe, $mosConfig_list_limit, $mosConfig_absolute_path;
		display::header(SC_MANAGE_FIELDS);
	if (!$arows) {
		echo "Custom fields have not been installed in your SimpleCaddy, <a href='index2.php?option=com_caddy&action=update'>click here to Update</a>";
		return;
	}
	$pageNav=$arows['nav'];
	$rows=$arows['lst'];
	?>
		<form method="post" name="adminForm" action="index2.php">
				<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
					<tr>
						<th width="20">
							<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" />
						</th>
						<th class="title" nowrap="nowrap"><?php echo SC_FIELDNAME ?></th>
						<th class="title" nowrap="nowrap"><?php echo SC_FIELDCAPTION ?></th>
						<th class="title tdright" nowrap="nowrap"><?php echo SC_FIELDTYPE ?></th>
						<th class="title tdright" nowrap="nowrap"><?php echo SC_FIELDLENGTH ?></th>
						<th class="title tdcenter" nowrap="nowrap"><?php echo SC_FIELDCLASS ?></th>
						<th class="title tdcenter" nowrap="nowrap"><?php echo SC_FIELDORDERING ?></th>
						<th class="title tdcenter" nowrap="nowrap"><?php echo SC_FIELDREQUIRED ?></th>
						<th class="title tdcenter" nowrap="nowrap"><?php echo SC_FIELDPUBLISHED ?></th>
						<th class="title" nowrap="nowrap">&nbsp;</th>

					</tr>
				<?php
				$k = 0;
				for ($i=0, $n=count( $rows ); $i < $n; $i++) {
				$row = &$rows[$i];
				?>
					<tr class="<?php echo "row$k"; ?>">
						<td width="20">
							<input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" />
						</td>
						<td width="40%">
							<a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')">
							<?php
							echo $row->name; ?>
							</a>
						</td>
						<td width="40%">
							<?php echo $row->caption; ?>
						</td>
						<td width="10%" class="tdright">
							<?php
							echo  $row->type;
							?>
						</td>
						<td width="10%" class="tdright">
							<?php echo $row->length; ?>
						</td>
						<td width="40%">
							<?php echo $row->classname; ?>
						</td>
						<td width="10%" class="tdright">
							<?php
							echo $row->ordering;
							?>
						</td>
						<td width="10%" class="tdright">
							<?php
							echo ($row->required? 'Yes':'No');
							?>
						</td>
						<td align="left" width="10%" class="tdcenter">
							<?php
								$published 	= self::published( $row, $i );
								echo $published;
							?>
						</td>
						<td>
							&nbsp;
						</td>
			<?php
				$k = 1 - $k; }

			?>
				</tr>
				<tr><td colspan="9">
					<?php
						echo $pageNav->getListFooter();
					?>
				</td></tr>
			</table>
			<input type="hidden" name="option" value="com_caddy" />
			<input type="hidden" name="action" value="fields" />
			<input type="hidden" name="task" value="" />
			<input type="hidden" name="boxchecked" value="0" />
			<input type="hidden" name="hidemainmenu" value="0" />
		</form>
		<?php
	}

	function showVouchers(& $arows, $field=null, $order=null ) {
	global $mainframe, $mosConfig_list_limit, $mosConfig_absolute_path;
	display::header(SC_VOUCHERS);
	$pageNav=$arows['nav'];
	$rows=$arows['lst'];
	?>
		<script language="javascript">
			function submitme(option) {
			a=option.split(",");
			document.adminForm.field.value=a[0];
			document.adminForm.order.value=a[1];
			document.adminForm.submit();
			}
		</script>
		<form method="post" name="adminForm" action="index2.php">
				<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
					<tr>
						<th width="20">
							<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" />
						</th>
						<th class="title" nowrap="nowrap"><?php echo SC_VOUCHERNAME ?><?php echo display::showSortArrows("name");?></th>
						<th class="title" nowrap="nowrap"><?php echo SC_VOUCHERFORMULA ?></th>
						<th class="title tdcenter" nowrap="nowrap"><?php echo SC_VOUCHERVALIDFROM ?><?php echo display::showSortArrows("validfrom");?></th>
						<th class="title tdcenter" nowrap="nowrap"><?php echo SC_VOUCHERVALIDTO ?><?php echo display::showSortArrows("validto");?></th>
						<th class="title tdcenter" nowrap="nowrap"><?php echo SC_VOUCHERGROUPNAME ?><?php echo display::showSortArrows("lot");?></th>
						<th class="title tdcenter" nowrap="nowrap"><?php echo SC_VOUCHERENABLED ?><?php echo display::showSortArrows("published");?></th>
						<th class="title tdcenter" nowrap="nowrap"><?php echo SC_VOUCHERAVAILABLE ?><?php echo display::showSortArrows("avqty");?></th>
						<th class="title" nowrap="nowrap">&nbsp;</th>

					</tr>
				<?php
				$k = 0;
				for ($i=0, $n=count( $rows ); $i < $n; $i++) {
				$row = &$rows[$i];
				?>
					<tr class="<?php echo "row$k"; ?>">
						<td width="20">
							<input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" />
						</td>
						<td width="450">
							<a href="#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')">
							<?php
							echo $row->name; ?>
							</a>
						</td>
						<td width="100" class="tdright">
							<?php
							echo $row->formula;
							?>
						</td>
						<td width="150">
							<?php echo ($row->validfrom>0?date("d-m-Y h:i:s", $row->validfrom):SC_NOT_SET); ?>
						</td>
						<td width="150" class="tdright">
							<?php
							echo ($row->validto>0?date("d-m-Y h:i:s", $row->validto):SC_NOT_SET);
							?>
						</td>
						<td width="100" class="tdright">
							<?php
							echo $row->lot;
							?>
						</td>
						<td align="left" width="20" class="tdcenter">
							<?php
								$published 	= self::published( $row, $i );
								echo $published;
							?>
						</td>
						<td width="50" class="tdright">
							<?php
							echo $row->avqty;
							?>
						</td>
						<td width="10%">
							&nbsp;
						</td>
			<?php
				$k = 1 - $k; }

			?>
				</tr>
				<tr><td colspan="9">
					<?php
						echo $pageNav->getListFooter();
					?>
				</td></tr>
			</table>
			<input type="hidden" name="option" value="com_caddy" />
			<input type="hidden" name="action" value="vouchers" />
			<input type="hidden" name="task" value="" />
			<input type="hidden" name="field" value="<?php echo $field;?>" />
			<input type="hidden" name="order" value="<?php echo $order;?>" />
			<input type="hidden" name="boxchecked" value="0" />
			<input type="hidden" name="hidemainmenu" value="0" />
		</form>
		<?php
	}

	function editProduct(&$a) {
	global $mainframe;

		$mainframe->addJS( JPATH_SITE.'/administrator/components/com_caddy/js/caddy.js');
		display::header(SC_PRODUCTS);
		$cfg=new sc_configuration();
		$currency=$cfg->get("currency");
		$tsep=$cfg->get("thousand_sep");
		$decsep=$cfg->get("decimal_sep");
		$decs=$cfg->get("decimals");
		$scats=$cfg->get("prodcats");
		$curalign=$cfg->get("curralign");
		$cats=explode("\r\n", $scats);
	?>

		<form method="post" name="adminForm" action="index2.php">
		<table class="adminform" width="100%"><tr><th><?php echo ($a->id ? SC_EDIT : SC_NEW)."&nbsp;".SC_PRODUCT;?></th><th>&nbsp;</th></tr>
		<tr>
			<td width="185"><?php echo SC_PRODUCT_CODE;?></td>
			<td><input type="text" name="prodcode" value="<?php echo $a->prodcode; ?>" maxlength="13"/><?php echo SC_MAX_10_CHAR;?></td>
		</tr>
		<tr>
			<td><?php echo SC_PRODUCT_NAME;?></td>
			<td><input type="text" name="shorttext" value="<?php echo $a->shorttext; ?>"/></td>
		</tr>
		<tr>
			<td><?php echo SC_PRODUCT_CATEGORY;?></td>
			<td>
			<select name="category">
			<?php
				foreach ($cats as $cat) {
					echo "<option value='$cat' ".($cat==$a->category ? ' selected' : '').">$cat</option>";
				}
			?>
			</select>
			</td>
		</tr>
		<tr>
			<td><?php echo SC_AVAILABLE_QTY;?></td>
			<td>
			<input type="text" name="av_qty" value="<?php echo $a->av_qty; ?>" size="10"/>
			</td>
		</tr>
		<tr>
			<td><?php echo SC_PRICE_PER_UNIT;?></td>
			<td>
			<?php
			if ($curalign==1) echo $currency;
			?>
			<input type="text" name="unitprice" value="<?php echo $a->unitprice; ?>"/> 
			<?php 
				if ($curalign==0) echo $currency;
				echo ' '.DO_NOT_FORMAT_YOUR_PRICE;
			?> 
			</td>
		</tr>
		<tr>
			<td><?php echo SC_SHIPPING_POINTS;?></td>
			<td>
			<input type="text" name="shippoints" value="<?php echo $a->shippoints; ?>" size="5"/>
			</td>
		</tr>
		<tr><td><?php echo SC_PUBLISHED;?></td>
		<td>
			<?php
				$show_hide = array (self::option(0, 'No'), self::option(1, 'Yes'),);
				foreach ($show_hide as $value) {
					echo "<input type='radio' value='$value->value' name='published' ".($a->published==$value->value?' checked':'').">$value->text";
				}
			?>
		</td>
		</tr>
		</table>
		<table class="adminform" width="100%"><tr><th><?php echo SC_OPTIONS;?></th><th>&nbsp;</th></tr>
		<tr>
		<td width="185"><?php echo stripslashes( SC_OPTIONS_TITLE);?></td>
		<td>
		<input type="text" name="optionstitle" value="<?php echo $a->optionstitle; ?>" />
		</td>
		</tr>
		<tr>
		<td><?php echo stripslashes( SC_IND_OPTIONS);?>
		</td>
		<td>
			<input type="button" name="addbtn" onclick="addRow()" value="<?php echo ADD_OPTION;?>" />&nbsp;<input type="button" name="delbtn" onclick="deleteRow()" value="<?php echo REMOVE_OPTION;?>" />
			<table id="mine" border="0" class="adminform">
			<tr>
                <th width="20">#</th>
                <th width="40"><?php echo SC_DESCRIPTION ?></th>
                <th width="40"><?php echo FORMULA;?></th>
                <th width="40"><?php echo CAPTION;?></th>
                <th width="80"><?php echo DEFAULT_SELECT;?></th>

			<?php
				$olines=explode("\r\n", trim($a->options));

				foreach ($olines as $key=>$line) {
					@list($shorttext, $formula, $caption, $defselect)=explode(":", $line);
					if (!$shorttext) break;
					echo "<tr>";
					echo "<td><input type='checkbox' name='tid$key' id='tid$key'></td>";
					echo "<td><input type='text' size='30' name='optionshorttext[]' value='$shorttext' ></td>" ;
					echo "<td><input type='text' name='optionformula[]' value='$formula' ></td>" ;
					echo "<td><input type='text' name='optioncaption[]' value='$caption' ></td>" ;
					echo "<td><input type='radio' name='optiondefselect' value='$key' ".($defselect=="default"?"checked":"")."></td>" ;
					echo "</tr>";
				}
			?>

			</table>
			<input type="hidden" name="rows" value="" id="rows" />
			<input type="hidden" name="rows2" value="" id="rows2" />
		</td>
		</tr>
		<tr>
		<td><?php echo SC_SHOW_AS;?>
		</td>
		<td>
			<select name="showas">
			<option value="1" <?php echo ($a->showas==1?" selected":"");?>><?php echo HORIZONTAL_RADIOBUTTONS;?></option>
			<option value="4" <?php echo ($a->showas==4?" selected":"");?>><?php echo VERTICAL_RADIOBUTTONS;?></option>
			<option value="2" <?php echo ($a->showas==2?" selected":"");?>><?php echo DROPDOWN_LIST;?></option>
			<option value="3" <?php echo ($a->showas==3?" selected":"");?>><?php echo STANDARD_LIST;?></option>
			<option value="5" <?php echo ($a->showas==5?" selected":"");?>><?php echo SINGLE_LINE_TEXTBOX;?></option>
			</select>
		</td>
		</tr>
		</table>
		<input type="hidden" name="id" value="<?php echo $a->id; ?>" />
		<input type="hidden" name="option" value="com_caddy" />
		<input type="hidden" name="action" value="products" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="hidemainmenu" value="0" />
		</form>
	<?php
	}

	function editField(&$a) {
		display::header(SC_OPTION_FIELDS);
	?>
		<form method="post" name="adminForm" action="index2.php">
		<table><tr><td width="40%" valign="top">
		<table class="adminform" width="100%"><tr><th><?php echo ($a->id ? SC_EDIT : SC_NEW)."&nbsp;".SC_OPTION_FIELDS;?></th><th>&nbsp;</th></tr>
		<tr>
			<td width="185"><?php echo SC_FIELDNAME;?></td>
			<td><input type="text" name="name" value="<?php echo $a->name; ?>" /></td>
		</tr>
		<tr>
			<td><?php echo SC_FIELDCAPTION;?></td>
			<td><input type="text" name="caption" value="<?php echo $a->caption; ?>"/></td>
		</tr>
		<tr>
			<td><?php echo SC_FIELDTYPE;?></td>
			<td>
			<select name="type">
				<option value="text" <?php echo $a->type == "text" ?"selected" : ""; ?>><?php echo 'Text';?></option>
				<option value="textarea" <?php echo $a->type == "textarea" ? "selected" : ""; ?>><?php echo 'Multiline Text';?></option>
				<option value="radio" <?php echo $a->type == "radio" ? "selected" : ""; ?>><?php echo 'Yes/No';?></option>
				<option value="checkbox" <?php echo $a->type == "checkbox" ? "selected" : ""; ?>><?php echo 'Checkbox';?></option>
				<option value="date" <?php echo $a->type == "date" ? "selected" : ""; ?>><?php echo 'Date';?></option>
				<option value="dropdown" <?php echo $a->type == "dropdown" ? "selected" : ""; ?>><?php echo 'Dropdown';?></option>
				<option value="divider" <?php echo $a->type == "divider" ? "selected" : ""; ?>><?php echo 'Divider';?></option>
			</select>
			</td>
		</tr>
		<tr>
		<td><?php echo SC_FIELDCONTENTS;?></td>
		<td><input type="text" name="fieldcontents" value="<?php echo $a->fieldcontents; ?>"/></td>
		</tr>
		<tr>
			<td><?php echo SC_FIELDLENGTH;?></td>
			<td>
			<input type="text" name="length" value="<?php echo $a->length; ?>"/>
			</td>
		</tr>
		<tr><td><?php echo SC_PUBLISHED;?></td>
		<td>
			<?php
				$show_hide = array (self::option(0, 'No'), self::option(1, 'Yes'),);
				foreach ($show_hide as $value) {
					echo "<input type='radio' value='$value->value' name='published' ".($a->published==$value->value?' checked':'').">$value->text";
				}
			?>
		</td>
		</tr>
		<tr>
		<td width="185"><?php echo stripslashes( SC_FIELDCLASS);?></td>
		<td>
		<input type="text" name="classname" value="<?php echo $a->classname; ?>" />
		</td>
		</tr>
		<tr>
		<td width="185"><?php echo stripslashes( SC_FIELDORDERING);?></td>
		<td>
		<input type="text" name="ordering" value="<?php echo $a->ordering; ?>" />
		</td>
		</tr>
		<tr><td><?php echo SC_FIELDREQUIRED;?></td>
		<td>
			<?php
				$show_hide = array (self::option(0, 'No'), self::option(1, 'Yes'),);
				foreach ($show_hide as $value) {
					echo "<input type='radio' value='$value->value' name='required' ".($a->required==$value->value?' checked':'').">$value->text";
				}
			?>
		</td>
		</tr>
		</table>
		</td>
		<td width="60%" valign="top">
		<table class="adminform" width="100%">
		<tr><th colspan="2"><?php echo SC_HELP;?></th></tr>
		<tr>
		<td valign="top" width="150"><?php echo SC_FIELDNAME;?></td><td valign="top"><?php echo SC_HELP_FIELDNAME;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo SC_FIELDCAPTION;?></td><td valign="top"><?php echo SC_HELP_CAPTION;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo SC_FIELDTYPE;?></td><td valign="top"><?php echo SC_HELP_TYPE;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo SC_FIELDCONTENTS;?></td><td valign="top"><?php echo SC_HELP_FIELDCONTENTS;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo SC_FIELDLENGTH;?></td><td valign="top"><?php echo SC_HELP_LENGTH;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo SC_PUBLISHED;?></td><td valign="top"><?php echo SC_HELP_PUBLISHED;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo SC_FIELDCLASS;?></td><td valign="top"><?php echo SC_HELP_CLASSNAME;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo SC_FIELDORDERING;?></td><td valign="top"><?php echo SC_HELP_ORDER;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo SC_FIELDREQUIRED;?></td><td valign="top"><?php echo SC_HELP_REQUIRED;?></td>
		</tr>
		</table>
		</td>
		</tr>
		</table>
		<input type="hidden" name="id" value="<?php echo $a->id; ?>" />
		<input type="hidden" name="option" value="com_caddy" />
		<input type="hidden" name="action" value="fields" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="hidemainmenu" value="0" />
		</form>
	<?php
	}

	function editVoucher(&$a) {
		global $mainframe, $config;
		display::header(SC_VOUCHERS);
		$mainframe->addJS(JPATH_SITE.'/components/com_caddy/js/datetimepicker.js');
	?>
		<form method="post" name="adminForm" action="index2.php">
		<table width="100%">
		<tr><td valign="top">
		<table class="adminform" width="100%"><tr><th><?php echo ($a->id ? SC_EDIT : SC_NEW)."&nbsp;".SC_VOUCHER;?></th><th>&nbsp;</th></tr>
		<tr>
			<td width="185"><?php echo SC_VOUCHERNAME;?></td>
			<td><input type="text" name="name" value="<?php echo $a->name; ?>" /></td>
		</tr>
		<tr>
			<td><?php echo SC_VOUCHERFORMULA;?></td>
			<td><input type="text" name="formula" value="<?php echo $a->formula; ?>" /></td>
		</tr>
		<tr class="row1"><td><?php echo SC_VOUCHERDATELIMITED;?></td>
		<td>
			<?php
				$show_hide = array (self::option(0, 'No'), self::option(1, 'Yes'),);
				foreach ($show_hide as $value) {
					echo "<input type='radio' value='$value->value' name='datelimited' ".($a->datelimited==$value->value?' checked':'').">$value->text";
				}
			?>
		</td>
		</tr>
		<tr class="row1">
			<td><?php echo SC_VOUCHERVALIDFROM;?></td>
			<td>
			<input type="text" size="40" name="validfrom" id="validfrom" value="<?php echo ($a->validfrom?date("d-m-Y h:i:s", $a->validfrom):""); ?>"/>
			<?php echo "&nbsp;<a href=\"javascript:NewCal('validfrom','ddMMyyyy',true ,24)\"><img src=\"components/com_caddy/images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"".SC_PICK_DATE."\"/></a>"; ?>
			</td>
		</tr>
		<tr class="row1">
			<td><?php echo SC_VOUCHERVALIDTO;?></td>
			<td>
			<input type="text" size="40" name="validto" id="validto" value="<?php echo ($a->validto?date("d-m-Y h:i:s", $a->validto):""); ?>"/>
			<?php echo "&nbsp;<a href=\"javascript:NewCal('validto','ddMMyyyy',true ,24)\"><img src=\"components/com_caddy/images/cal.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"".SC_PICK_DATE."\"/></a>"; ?>
			</td>
		</tr>

		<tr><td><?php echo SC_VOUCHERQTYLIMITED;?></td>
		<td>
			<?php
				$show_hide = array (self::option(0, 'No'), self::option(1, 'Yes'),);
				foreach ($show_hide as $value) {
					echo "<input type='radio' value='$value->value' name='qtylimited' ".($a->qtylimited==$value->value?' checked':'').">$value->text";
				}
			?>
		</td>
		</tr>
		<tr>
			<td><?php echo SC_VOUCHERAVQTY;?></td>
			<td>
			<input type="text" name="avqty" value="<?php echo $a->avqty; ?>"/>
			</td>
		</tr>


		<tr class="row1"><td><?php echo SC_VOUCHERENABLED;?></td>
		<td>
			<?php
				$show_hide = array (self::option(0, 'No'), self::option(1, 'Yes'),);
				foreach ($show_hide as $value) {
					echo "<input type='radio' value='$value->value' name='published' ".($a->published==$value->value?' checked':'').">$value->text";
				}
			?>
		</td>
		</tr>
		<tr class="row1">
		<td width="185"><?php echo stripslashes( SC_VOUCHERGROUPNAME);?></td>
		<td>
		<input type="text" name="lot" value="<?php echo $a->lot; ?>" />
		</td>
		</tr>

		</table>
		</td>
		<td width="60%" valign="top">

		<table class="adminform" width="100%">
		<tr><th colspan="2"><?php echo SC_HELP;?></th></tr>
		<tr>
		<td valign="top" width="150"><?php echo SC_FIELDNAME;?></td><td valign="top"><?php echo SC_HELP_FIELDNAME;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo VOUCHER_FORMULA;?></td><td valign="top"><?php echo SC_HELP_VFORMULA;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo DATE_LIMITED;?></td><td valign="top"><?php echo SC_HELP_VDATELIMITED;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo VALIDITY;?></td><td valign="top"><?php echo SC_HELP_VVALIDITY;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo QUANTITY_LIMITED;?></td><td valign="top"><?php echo SC_HELP_VQLIMITED;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo AVAILABLE_QUANTITY;?></td><td valign="top"><?php echo SC_HELP_VQANTITY;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo SC_ENABLED;?></td><td valign="top"><?php echo SC_HELP_VENABLED;?></td>
		</tr>
		<tr>
		<td valign="top"><?php echo SC_VOUCHERGROUPNAME;?></td><td valign="top"><?php echo SC_HELP_VGROUP;?></td>
		</tr>
		</table>

		</td>
		</tr>
		</table>
		<input type="hidden" name="id" value="<?php echo $a->id; ?>" />
		<input type="hidden" name="option" value="com_caddy" />
		<input type="hidden" name="action" value="vouchers" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="hidemainmenu" value="0" />
		</form>
	<?php
	}


	function showOrders( & $lists, $field=null, $order=null) {
	global $mainframe, $mosConfig_list_limit, $mosConfig_absolute_path;
		display::header(SC_ORDERS);
		$cfg=new sc_configuration();
		$currency=$cfg->get("currency");
		$tsep=$cfg->get("thousand_sep");
		$decsep=$cfg->get("decimal_sep");
		$decs=$cfg->get("decimals");
		$pageNav=$lists['nav'];
		$rows=$lists['lst'];

	?>
		<script language="javascript">
			function submitme(option) {
			a=option.split(",");
			document.adminForm.field.value=a[0];
			document.adminForm.order.value=a[1];
			document.adminForm.submit();
			}
		</script>
		<form method="post" name="adminForm" action="index2.php">
			<table>
				<tr>
					<td width="100%">
						<?php echo 'Filter'; ?>:
						<input type="text" name="search" id="search" value="<?php echo $lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
						<button onclick="this.form.submit();"><?php echo 'Go' ; ?></button>
						<button onclick="document.getElementById('search').value='';this.form.submit();"><?php echo 'Reset'; ?></button>
					</td>
				</tr>
			</table>
				<table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">
					<tr>
						<th width="20">
							<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows ); ?>);" />
						</th>
						<th class="title" nowrap="nowrap">ID</th>
						<th class="title" nowrap="nowrap"><?php echo SC_NAME ?>&nbsp;<?php echo display::showSortArrows("name");?></th>
						<th class="title" nowrap="nowrap"><?php echo SC_EMAIL ?>&nbsp;<?php echo display::showSortArrows("email");?></th>
						<th class="title tdright" nowrap="nowrap"><?php echo SC_DATE ?>&nbsp;<?php echo display::showSortArrows("orderdt");?></th>
						<th class="title tdright" nowrap="nowrap"><?php echo SC_TOTAL ?>&nbsp;<?php echo display::showSortArrows("total");?></th>
						<th class="title" nowrap="nowrap"><?php echo SC_ORDER_STATUS ?>&nbsp;<?php echo display::showSortArrows("status");?></th>
						<th class="title" nowrap="nowrap">&nbsp;</th>
					</tr>
				<?php
				$k = 0;
				for ($i=0, $n=count( $rows ); $i < $n; $i++) {
				$row = &$rows[$i];
				?>
					<tr class="<?php echo "row$k"; ?>">
						<td width="20">
							<input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onclick="isChecked(this.checked);" />
						</td>
						<td width="20">
							<a href="#view" onclick="return listItemTask('cb<?php echo $i;?>','view')">
							<?php echo $row->id; ?>
							</a>
						</td>
						<td width="10%">
							<a href="#view" onclick="return listItemTask('cb<?php echo $i;?>','view')">
							<?php echo $row->name; ?>
							</a>
						</td>
						<td width="10%">
							<?php echo "<a href='mailto:$row->email'>$row->email</a>"; ?>
						</td>
						<td width="10%" class="tdright">
							<?php
							echo date("d-m-Y", $row->orderdt); ?>
						</td>
						<td width="10%" class="tdright">
						<?php
							echo number_format($row->total + $row->tax, $decs, $decsep, $tsep);
						?>
						</td>
						<td>
							<?php echo "<span class='".strtolower($row->status)."'>$row->status</span>"; ?>
						</td>
						<td>
							&nbsp;
						</td>
			<?php
				$k = 1 - $k; }

			?>
				</tr>
			</table>
			<?php
				echo $pageNav->getListFooter();
				$field=mosGetParam($_REQUEST, 'field', '');
				$order=mosGetParam($_REQUEST, 'order', '');
			?>
			<input type="hidden" name="option" value="com_caddy" />
			<input type="hidden" name="action" value="orders" />
			<input type="hidden" name="task" value="" />
			<input type="hidden" name="field" value="<?php echo $field;?>" />
			<input type="hidden" name="order" value="<?php echo $order;?>" />
			<input type="hidden" name="boxchecked" value="0" />
			<input type="hidden" name="hidemainmenu" value="0" />
		</form>
		<?php
	}

	function editOrder($a, $items, $pageNav) {
	global $mainframe, $mosConfig_list_limit, $mosConfig_absolute_path;
		display::header(SC_ORDER);
	$cfg=new sc_configuration();
	$currency=$cfg->get("currency");
	$tsep=$cfg->get("thousand_sep");
	$decsep=$cfg->get("decimal_sep");
	$decs=$cfg->get("decimals");
	$align=$cfg->get("curralign"); // before amount==1
	// hardcoded fields from old simplecaddy <1.7
	$standardfields=array("name", "email", "address", "codepostal", "city", "telephone", "ipaddress" );
	$statuses=explode("\n", $cfg->get("ostatus"));
	?>
		<form method="post" name="adminForm" action="index2.php">
		<table class="adminform" width="100%"><tr><th class="title"><?php echo SC_ORDER;?></th><th>&nbsp;</th></tr>
		<tr>
			<td width="185"><?php echo SC_DATE;?></td>
			<td>
			<?php echo date("d-m-Y H:i:s", $a->orderdt); ?>
			</td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_NAME;?></td>
			<td><?php echo $a->name; ?></td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_EMAIL;?></td>
			<td><?php echo "<a href='mailto:$a->email'>$a->email</a>";?></td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_ADDRESS;?></td>
			<td>
			<?php echo $a->address; ?>
			</td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_ZIPCODE;?></td>
			<td>
			<?php echo $a->codepostal; ?>
			</td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_CITY;?></td>
			<td>
			<?php echo $a->city; ?>
			</td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_PHONE;?></td>
			<td>
			<?php echo $a->telephone; ?>
			</td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_IP_ADDRESS;?></td>
			<td>
			<?php 
	           $iplink = '&nbsp;<a href="http://whois.domaintools.com/'.$a->ipaddress.'" target="_blank" class="scbutton">'.SC_CHECKIP."</a>";
				echo $a->ipaddress;
				echo $iplink; 
 			?>
 			<input type="hidden" name="ipaddress" value="<?php echo $a->ipaddress;?>" />
			</td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_SHIP_REGION;?></td>
			<td>
			<?php
				echo $a->shipRegion; ?>
			</td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_SHIP_COST;?></td>
			<td>
			<?php
				if ($align==1) echo $currency. "&nbsp;";
                    //var_dump($a);
				echo number_format(doubleval($a->shipCost), $decs, $decsep, $tsep);
				if ($align==0) echo "&nbsp;". $currency; 
				?>
			</td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_SUBTOTAL;?></td>
			<td>
			<?php
				if ($align==1) echo $currency. "&nbsp;";
				echo number_format($a->total, $decs, $decsep, $tsep);
				if ($align==0) echo "&nbsp;". $currency;
				?> 
			</td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_TAX;?></td>
			<td>
			<?php
				if ($align==1) echo $currency. "&nbsp;";
				echo number_format($a->tax, $decs, $decsep, $tsep);
				if ($align==0) echo "&nbsp;". $currency;
				?> 
			</td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_TOTAL;?></td>
			<td>
			<?php
				if ($align==1) echo $currency. "&nbsp;";
				echo number_format($a->total + $a->tax, $decs, $decsep, $tsep);
				if ($align==0) echo "&nbsp;". $currency;
				?> 
			</td>
		</tr>
		<?php
		if (@$a->customfields) {
			echo "<tr><th>".CUSTOM_FIELDS."</th><th>&nbsp;</th></tr>";
			$fields=new fields();
			$fieldlist=$fields->getPublishedFieldsArray();
			$acfields=unserialize($a->customfields);

			foreach ($fieldlist as $key=>$cfield) {
				if (!in_array($cfield, $standardfields)) { // show only the fields that are not hardcoded
					if (isset($acfields[$cfield])) {
						echo "<tr>";
						echo "<td width=\"185\">$cfield</td>";
						echo "<td>".$acfields[$cfield]."</td>";
						echo "</tr>";
					}
				}
			}

		}
		?>
		<tr>
		<td><a href="index.php?option=com_caddy&action=orders&task=email&oid=<?php echo $a->id?>" class="scbutton"><?php echo RESEND_ORDER_CONFIRMATION_EMAIL;?></a></td>
		</tr>
		<tr>
			<td width="185"><?php echo SC_ORDER_STATUS;?></td>
			<td>
			<?php
				echo "<select name='edtostatus'>";
				foreach ($statuses as $status) {
					$selected=(strtolower($a->status)==strtolower(trim($status))?" selected":"");
					echo "<option value='".trim($status)."' $selected>$status</option>\n";

				}
				echo "</select>";
			?>
			</td>
		</tr>
		</table>
		<table class="adminlist" width="100%" cellpadding="4" cellspacing="0" border="0" >
		<tr><th colspan="7"><?php echo SC_DETAILS;?></th></tr>
		<tr>
			<th class="title"><?php echo SC_CODE;?></th>
			<th class="title"><?php echo SC_QUANTITY;?></th>
			<th class="title tdright"><?php echo SC_PRICE_PER_UNIT;?></th>
			<th class="title tdright"><?php echo SC_TOTAL;?></th>
			<th class="title"><?php echo SC_PRODUCT_NAME;?></th>
			<th class="title"><?php echo SC_PRODUCT_OPTION;?></th>
			<th class="title"><?php echo SC_ACTION;?></th>
		</tr>
		<?php
		$k = 0;
		for ($i=0, $n=count( $items ); $i < $n; $i++) {
		$row = &$items[$i];
		?>
			<tr class="<?php echo "row$k"; ?>">
				<td width="10%">
					<?php echo $row->prodcode; ?>
				</td>
				<td width="30">
					<?php
						echo $row->qty;
					?>
				</td>
				<td width="10%" class="tdright">
					<?php
						echo number_format($row->unitprice, $decs, $decsep, $tsep);
					?>
				</td>
				<td class="tdright">
					<?php
						echo number_format($row->total, $decs, $decsep, $tsep);
					?>
				</td>
				<td width="40%">
					<?php echo $row->shorttext; ?>
				</td>
				<td>
					<?php echo $row->option; ?>&nbsp;
				</td>
				<td>
					<?php
					echo "<a class=\"scbutton\" href=\"index2.php?option=com_caddy&action=products&task=decstore&pid=$row->prodcode&qty=$row->qty&order=$a->id\">".SC_DECSTORE."</a>";
					?>
				</td>
				<?php
					$k = 1 - $k; }
				?>
			</tr>
			<?php
				$field=mosGetParam($_REQUEST,  'field', '');
				$order=mosGetParam($_REQUEST, 'order', '');
			?>
		</table>
		<input type="hidden" name="id" value="<?php echo ($a->id?"$a->id":"-1"); ?>">
		<input type="hidden" name="option" value="com_caddy" />
		<input type="hidden" name="action" value="orders" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="order" value="<?php echo $order; ?>" />
		<input type="hidden" name="field" value="<?php echo $field; ?>" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="hidemainmenu" value="0" />
		</form>
	<?php
	}

	function header($header='') {
	global $mainframe;
		$mainframe->addCSS('administrator/components/com_caddy/css/simplecaddy.css' );
    ?>
     <h1>JoiCaddy::<?php echo $header;?></h1> <br />
    <?php
	}

	function view_prod($alist) {
	global $mainframe;
	$stylesheet= JPATH_COMPONENT.DS.'css'.DS.'simplecaddy.css';
	$e_name	=	mosGetParam($_REQUEST,  'e_name' );  //2009-09-17-updated
		?>
		<link rel="stylesheet" href="<?php echo $stylesheet ?>" type="text/css" />
		<script type="text/javascript" language="javascript">
			function insertCode(plugincode) {
				var editor = '<?php echo $e_name; ?>';  //2009-09-17-updated
				var sccode = '{simplecaddy code='+plugincode+'}';
				window.parent.jInsertEditorText(sccode, editor);  //2009-09-17-updated
				window.parent.document.getElementById('sbox-window').close();
			}
			function insertCat(plugincode) {
				var editor = '<?php echo $e_name; ?>';  //2009-09-17-updated
				var sccode = '{simplecaddy category='+plugincode+'}';
				window.parent.jInsertEditorText(sccode, editor);  //2009-09-17-updated
				window.parent.document.getElementById('sbox-window').close();
			}
		</script>
		<?php
		echo "<table class='codelist' width='100%'>";
		echo "<tr><th>".SC_CLICK_CODE."</th></tr>";
		$k=0;
		foreach ($alist as $product) {
			echo "<tr class='row$k'><td>$product->category&nbsp;<a class='codelist' href='#' onclick=\"insertCode('$product->prodcode');\">$product->shorttext (code: $product->prodcode)</a></td></tr>";
			$k=1-$k;
		}
		echo "</table>";
		$cfg=new sc_configuration();
		$aclist=$cfg->get("prodcats");
		$clist=explode("\r\n", $aclist);
		echo "<table class='codelist' width='100%'>";

        echo "<tr><th>".SC_CLICK_CATEGORY."</th></tr>";


		$k=0;
		foreach ($clist as $key=>$cat) {
			echo "<tr class='row$k'><td><a class='codelist' href='#' onclick=\"insertCat('".$cat."');\">$cat</a></td></tr>";
			$k=1-$k;
		}
		echo "</table>";
	}
}